package com.pacy.pacybaseproject.viewmodels;

import android.app.Application;
import android.os.Bundle;
import android.view.View;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.pacy.pacybaseproject.R;
import com.pacy.pacybaseproject.activitys.AcDetailActivity;
import com.pacy.pacybaseproject.activitys.AllReceiveActivity;
import com.pacy.pacybaseproject.activitys.ExchangeDetailActivity;
import com.pacy.pacybaseproject.activitys.MsgListActivity;
import com.pacy.pacybaseproject.activitys.RedempPointsActivity;
import com.pacy.pacybaseproject.activitys.RedempPointsExPayActivity;
import com.pacy.pacybaseproject.adapters.IntegralAcAdapter;
import com.pacy.pacybaseproject.adapters.IntegralExchangeAdapter;
import com.pacy.pacybaseproject.adapters.IntegralPayAdapter;
import com.pacy.pacybaseproject.beans.MenuBean;
import com.pacy.pacybaseproject.utils.Constants;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.annotations.NonNull;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * @author PACY
 * @date 2023/12/20
 * description:
 */
public class IntegralViewModel extends BaseViewModel {
    public IntegralAcAdapter acAdapter;
    public IntegralExchangeAdapter exAdapter;
    public IntegralPayAdapter dxAdapter;
    public IntegralViewModel(@NonNull Application application) {
        super(application);
    }
    @Override
    protected void init() {
        super.init();
        initAdapter();
    }


    public BindingCommand toAllPage=new BindingCommand(() -> startActivity(AllReceiveActivity.class));
    //兑换历史
    public BindingCommand toMsgPage=new BindingCommand(() -> startActivity(MsgListActivity.class));
    //兑换列表
    public BindingCommand toExchangePage=new BindingCommand(() -> startActivity(RedempPointsActivity.class));
    //合作门店
    public BindingCommand toExPayPage=new BindingCommand(() -> startActivity(RedempPointsExPayActivity.class));
    public void initAdapter(){
        acAdapter=new IntegralAcAdapter();
        List<MenuBean> datas=new ArrayList<>();
        datas.add(new MenuBean("积分夺宝", R.drawable.delete_jifen_ac_1,"抽文创公仔","积分抽文创公仔"));
        datas.add(new MenuBean("积分捐", R.drawable.delete_jifen_ac_2,"捐爱心","小积分 大爱心"));
        datas.add(new MenuBean("话费充值", R.drawable.delete_jifen_ac_3,"话费充值","积分抵话费"));
        acAdapter.setNewInstance(datas);
        acAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
//                startActivity(AcDetailActivity.class);
            }
        });

        exAdapter=new IntegralExchangeAdapter();
        List<MenuBean> dataEx=new ArrayList<>();
        dataEx.add(new MenuBean("滴滴10元现金券","10","10","滴滴打车立减",R.drawable.delete_exchange_1));
        dataEx.add(new MenuBean("公交乘坐周卡","200","50","刷码乘公交免费",R.drawable.delete_exchange_2));
        dataEx.add(new MenuBean("交通文创吉祥物","20","20","文创吉祥物兑换",R.drawable.delete_exchange_3));
        exAdapter.setNewInstance(dataEx);
        exAdapter.addChildClickViewIds(R.id.exchange_slt);
        exAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter<?, ?> adapter, View view, int position) {
                Bundle bundle=new Bundle();
                bundle.putString("title",exAdapter.getItem(position).getTitle());
                bundle.putString("scroNum",exAdapter.getItem(position).getPrice());
                bundle.putString("priceNum",exAdapter.getItem(position).getPrice2());
                bundle.putString("slogen",exAdapter.getItem(position).getSlogan());
                startActivity(ExchangeDetailActivity.class,bundle);
            }
        });
        exAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter<?, ?> adapter, View view, int position) {
                if(view.getId()==R.id.exchange_slt){
                    Bundle bundle=new Bundle();
                    bundle.putString("title",exAdapter.getItem(position).getTitle());
                    bundle.putString("scroNum",exAdapter.getItem(position).getPrice());
                    bundle.putString("priceNum",exAdapter.getItem(position).getPrice2());
                    bundle.putString("slogen",exAdapter.getItem(position).getSlogan());
                    startActivity(ExchangeDetailActivity.class,bundle);
                }
            }
        });

        dxAdapter=new IntegralPayAdapter();
        List<MenuBean> dataDx=new ArrayList<>();
        dataDx.add(new MenuBean("火炉自助餐(廊坊万达店)",R.drawable.delete_dx_1,"678m"));
        dataDx.add(new MenuBean("二宽 · 家宴（文明路店）",R.drawable.delete_dx_2,"445m"));
        dataDx.add(new MenuBean("张家菜馆（二店）",R.drawable.delete_dx_3,"234m"));
        dxAdapter.setNewInstance(dataDx);
    }
}
